/*---------------------------------------------------------------------------------

	by GugloPWN

---------------------------------------------------------------------------------*/

#ifndef PLAYER_H
#define PLAYER_H

#include "block.h"
#include "map.h"
#include "MD2.h"


#include <nds.h>
#include <math.h>
#include <stdio.h>


#define FREQUENCE 5




class player {

	public:

	player() {getdefaultplayer();}
	void getdefaultplayer();
	
	void loadcharmodel();
	
	void updateplayer();
	void setframe();
	void setplayercam();
	
	void drawplayer();
	void drawplayercolmap();
	void drawplaymap() {m->drawmap(mapx,mapy);}
	void drawplaymapcolmap() {m->drawmapcolmap(mapx,mapy);}
	
	inline float getx() {return x;}
	inline float gety() {return y;}
	inline float getz() {return z;}
	inline int getmapx() {return mapx;}
	inline int getmapy() {return mapy;}
	inline void setmap(map *mymap) {m = mymap;}
	
	
	private:
	void gettileinfo(float x, float y, int* b, int*p);
	
	bool checkrailcol();
	bool closerailcol(rail r, int i);
	
	bool checkxcol();
	bool checkycol();
	bool handlez();
	
	map *m;
	
	int mapx;
	int mapy;
	
	float x;
	float y;
	float z;
	float vx;
	float vy;
	float vz;
	
	float camx;
	float camy;
	float camz;
	
	int dir;
	
	int animation;
	
	int paint;
	int score;
	int charmodel;
	bool isground;
	bool isgrindrail;
	bool isgrindwall;
	bool isjump;
	bool waslastplusx;
	bool waslastplusy;
	
	int currail;
	int pastrail;
	
	int airtime;
	int walltime;
	
	float maxspeed;
	float maxcamdist;
	float mincamdist;
	
	
	
	//MD2 Loader stuff
	float zoom;
	int32 scale;
	
	int Texture[1];
	int TexturePal[1];
	int textsize;
	MD2Entity Model;
	bool ModelEnable;

	//these two will prolly be changed to be more dynamic, AKA ingame animation
	int frame, change;
	
};

#endif

